package com.example.materialcostsystembackend.controller;

import com.example.materialcostsystembackend.model.User;
import com.example.materialcostsystembackend.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.UUID;

@RestController
@RequestMapping("/api/auth")
public class AuthController {

    @Autowired
    private UserRepository userRepository;

    @PostMapping("/login")
    public ResponseEntity<Object> login(@RequestParam String username, @RequestParam String password) {
        if ("huashun".equals(username) && "huashun".equals(password)) {
            String token = UUID.randomUUID().toString();
            return ResponseEntity.ok(Map.of("token", token));
        }
        return ResponseEntity.status(401).body("用户名或密码错误");
    }

}

